<?php
namespace Api\Controller;
use Think\Controller;
class CheckController extends CommonController {
    public function _initialize(){
		
	}
	
	public function typecheck(){
		$Type = M('Type');
		$Subtype = M('Subtype');
		
		$list = $Type->select();
		$data = array();
		foreach( $list as $vo){
			$typenum = $vo['typenum'];
			$sublist = $Subtype->where("typenum={$typenum}")->select();
			$replylist = array();
			foreach( $sublist as $vo1){
				$replylist[] = array(
					'subname'	=>	$vo1['subname'],
					'subnum'		=>	$vo1['subnum'],
					'typenum'	=>	$vo1['typenum']
				);
			}
			$vo['reply'] = $replylist;
			$data[] = $vo; 
			
		}
		
		$this->response( true , 0 , $data , true);
	}
	
	public function introcheck(){
		$Type = M('Type');
		$Subtype = M('Subtype');
		$Ware = M('Ware');
		
		$list = $Type->limit(0,1)->select();
		$data = array();
		foreach( $list as $vo){
			$typenum = $vo['typenum'];
			$sublist = $Subtype->where("typenum={$typenum}")->select();
			$warelist = $Ware->order("addtime desc")->where("typenum={$typenum}")->select();
			$replylist = array();
			$replylist1 = array();
			foreach( $sublist as $vo1){
				$replylist[] = array(
					'subname'	=>	$vo1['subname']
				);
			}
			foreach( $warelist as $vo2){
				$replylist1[] = array(
					'id'		=>	$vo2['id'],
					'ware_name'	=>	$vo2['ware_name'],
					'price'		=>	$vo2['price'],
					'head_img'	=>	$vo2['head_img']
				);
			}
			$vo['reply'] = $replylist;
			$vo['reply1'] = $replylist1;
			$data[] = $vo; 
			
		}
		
		$this->response( true , 0 , $data , true);
	}
}
